///////////////////////////////////////////////////////////
///////////////// Have an itch? Scratch it! ///////////////
///////////////////////// SCRATCH /////////////////////////
/////////////////////  A MUD  Server   ////////////////////
///////////////////// By: Jared Devall ////////////////////
/////////////////////      Thanks:     ////////////////////
/////////////////////  DIKU/Merc/ROM   ////////////////////
///////////////////// Aetas/Deus Gang  ////////////////////
/////////////////////       Beej       ////////////////////
///////////////////////////////////////////////////////////

#ifndef __SMYSQL_H_
#define __SMYSQL_H_

#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <mysql/mysql.h>

class Mysql {
	public:
	typedef struct st_mysql MYSQL;
	typedef std::map< std::string, std::string > LMAP;
	typedef std::vector< LMAP > RESULT;
	
	private:
	MYSQL * _dbinstance;
	
	public:
	Mysql ( const char * hostname, const char * username, const char * password, const char * dbname );
	~Mysql( );
	
	bool Query( const char * query );
	int QueryRows( const char * query );
	bool RealQuery( const char * query );
	std::string EscapeString( const std::string & );
	bool Load( const char * query );
	std::vector< std::map< std::string, std::string > > _info;
	static Mysql &Instance();
};

// Our singleton instance
inline Mysql &Mysql::Instance() {
	static Mysql instance( "localhost", "rendelven", "rendelhaven", "rendelven" );;
	return instance;
}

#endif // _SMYSQL_H
